package cn.domain;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 
 * @author Lynx
 * @date 2015��4��18��
 */
@SuppressWarnings("serial")
public class Tunnel implements Serializable {
	private int id;
	private String devicedID;
	private String type;
	private String name;
	private boolean symbol;
	private int precision = 1;
	private double data;
	private boolean sswitch;
	private boolean onoff;
	private boolean inout;
	private String deviceid;

	public String getDeviceid() {
		return deviceid;
	}

	public void setDeviceid(String deviceid) {
		this.deviceid = deviceid;
	}

	private Date timeStamp;

	public String getDevicedID() {
		return devicedID;
	}

	public void setDevicedID(String devicedID) {
		this.devicedID = devicedID;
	}

	public Tunnel() {
		timeStamp = new Date(System.currentTimeMillis());
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

	}

	public String getTimeStamp() {

		DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

		return df.format(timeStamp);
	}

	public void setTimeStamp(Date timeStamp) {
		this.timeStamp = timeStamp;
	}

	public boolean isOnoff() {
		return onoff;
	}

	public void setOnoff(boolean onoff) {
		this.onoff = onoff;
	}

	public boolean isInout() {
		return inout;
	}

	public void setInout(boolean inout) {
		this.inout = inout;
	}

	private String unit = " ";

	public boolean isSswitch() {
		return sswitch;
	}

	public void setSswitch(boolean sswitch) {
		this.sswitch = sswitch;
	}

	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
		this.name = TunnelType.getTunnelNameByKey(type);
		this.unit = TunnelType.getTunnelUnitByKey(type);
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean isSymbol() {
		return symbol;
	}

	public void setSymbol(boolean symbol) {
		this.symbol = symbol;
	}

	public int getPrecision() {
		return precision;
	}

	public void setPrecision(int precision) {
		this.precision = precision;
	}

	public double getData() {
		return data;
	}

	public void setData(double data) {
		this.data = data;
	}

	@Override
	public String toString() {
		if (!isSswitch()) {
			String infor = "时间：" + this.getTimeStamp() + "  通道 id:"
					+ this.getId() + " 符号:" + this.isSymbol() + " 精度:"
					+ this.getPrecision() + " " + getName() + "的数据:"
					+ +this.getData() + this.getUnit();
			return infor;
		} else {
			String infor = "开关信息:  ID：" + getId() + " type开关名称: " + getType()
					+ " 状态: " + (isOnoff() ? "开" : "关" + "name" + getName());
			return infor;
		}
	}
}
